import 'dart:convert' show json;
import 'itemData.dart';

class DataInfo {
  List<ItemData> list;
  Info info;

  DataInfo.fromParams({this.list, this.info});

  factory DataInfo(jsonStr) => jsonStr == null
      ? null
      : jsonStr is String
          ? new DataInfo.fromJson(json.decode(jsonStr))
          : new DataInfo.fromJson(jsonStr);

  DataInfo.fromJson(jsonRes) {
    list = jsonRes['list'] == null ? null : [];

    for (var listItem in list == null ? [] : jsonRes['list']) {
      list.add(listItem == null ? null : new ItemData.fromJson(listItem));
    }

    info = jsonRes['info'] == null ? null : new Info.fromJson(jsonRes['info']);
  }

  @override
  String toString() {
    return '{"list": $list,"info": $info}';
  }
}

class Info {
  int count;
  int page;
  String maxid;
  String maxtime;
  String vendor;

  Info.fromParams(
      {this.count, this.page, this.maxid, this.maxtime, this.vendor});

  Info.fromJson(jsonRes) {
    count = jsonRes['count'];
    page = jsonRes['page'];
    maxid = jsonRes['maxid'];
    maxtime = jsonRes['maxtime'];
    vendor = jsonRes['vendor'];
  }

  @override
  String toString() {
    return '{"count": $count,"page": $page,"maxid": ${maxid != null ? '${json.encode(maxid)}' : 'null'},"maxtime": ${maxtime != null ? '${json.encode(maxtime)}' : 'null'},"vendor": ${vendor != null ? '${json.encode(vendor)}' : 'null'}}';
  }
}
